class OuterClass {
    public int data = 1;
    private int data2 = 2;
    public static int data3 = 3;

    class InnerClass {
        public int data = 10;
        public int data4 = 4;
        public static final int data5 = 5;

        private int data6 = 6;

        public void test() {
            System.out.println(data);//自己有有限访问自己的
            System.out.println(OuterClass.this.data);//此时访问外部类
            System.out.println(this.data);
            System.out.println(data2);
            System.out.println(data4);
            System.out.println("InnerClass::test()");
        }
    }

    public void test() {
        System.out.println("OutterClass::test()");
    }
}

class Out {
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    static class InClass {
        public int data4 = 4;
        public static int data5 = 5;
        private int data6 = 6;

        public void test() {
            Out out = new Out();
            System.out.println(out.data1);
            System.out.println(data2);//只能调用外部类的静态成员或方法
            System.out.println(out.data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println("InClass::test()");
        }
    }

    public void test() {
        System.out.println("Out::test()");
    }
}

interface IA {
    void test();
}

public class Test2 {
    public static void main(String[] args) {

        new IA() {
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法！");
            }
        };

        IA ia = new IA() {
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法！");
            }
        };
    }



    public void func() {
        class AA {
            public int a;
        }
        AA aa = new AA();
        System.out.println(aa.a);
    }

    public static void main3(String[] args) {
        Test2 test2 = new Test2();
        test2.func();
    }

    public static void main1(String[] args) {
        //静态内部类实例化不需要有外部类的引用
        Out.InClass inClass = new Out.InClass();
        inClass.test();
    }

    public static void main2(String[] args) {
        //InnerClass innerClass = new InnerClass();
        //不能够实例化实例内部类

        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.test();
    }
}
